package com.hnqcgczy.db;

import com.mchange.v2.c3p0.ComboPooledDataSource;

import java.sql.Connection;
import java.sql.SQLException;

/***
 * 使用C3p0连接
 */
public class MyConn implements IConnection{
    //C3p0核心对象
    ComboPooledDataSource dataSource=new ComboPooledDataSource();
    @Override
    public Connection getConnectionByMysql() throws SQLException {
        //返回连接对象
        return dataSource.getConnection();
    }

    @Override
    public Connection getConnectionByOracle() throws SQLException {
        return null;
    }

    public static void main(String[] args) {
        try {
            System.out.println(new MyConn().getConnectionByMysql().isClosed());
        } catch (SQLException throwables) {
            throwables.printStackTrace();
        }
    }
}
